﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace Orders.Utils
{
  public static class EventLogHandler
  {
    private const string APPLICATIONLOG = "Application";
    private const string SOURCE = "CBM Order Server";

    static EventLogHandler()
    {
      if (!EventLog.SourceExists(SOURCE))
        EventLog.CreateEventSource(SOURCE, APPLICATIONLOG);
    }

    public static void Log(string message, EventLogEntryType type)
    {
      EventLog.WriteEntry(SOURCE, message, type);
    }

    public static void LogError(string message)
    {
      Log(message, EventLogEntryType.Error);
    }

    public static void LogInformation(string message)
    {
      Log(message, EventLogEntryType.Information);
    }

    public static void LogWarning(string message)
    {
      Log(message, EventLogEntryType.Warning);
    }
  }
}
